package com.sf.fy.uav.applet.order.controller;

import com.sf.fy.uav.applet.order.controller.service.OrderService;
import com.sf.fy.uav.common.enums.ServicePrefixEnum;
import com.sf.fy.uav.common.response.order.PlaceOrderResponse;
import com.sf.fy.uav.common.utils.BeanUtil;
import com.sf.fy.uav.common.utils.RedisPrefixKey;
import com.sf.fy.uav.common.utils.Rs;
import com.sf.fy.uav.order.entity.PaySetting;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ltq
 */
@RestController
@RequestMapping("/sys/pay/")
public class PayController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("get-pay-settings")
    @Operation(tags = "获取再次发起支付配置", description = "获取再次发起支付配置")
    public Rs<PlaceOrderResponse> getPaySettings(@RequestParam String orderId) {
        PaySetting paySetting = (PaySetting) redisTemplate.opsForValue().get(ServicePrefixEnum.RESCUE + RedisPrefixKey.PAY_SETTING + orderId);
        return Rs.success(BeanUtil.copyProperties(paySetting, PlaceOrderResponse.class));
    }
}
